package com.ribbon.demo.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author Johnson
 * @date 2020/12/24 10:14
 */
@RestController
public class ServiceAController {





    @GetMapping("/say")
    public String sayHello() {
        return say();
    }




    @Bean
    @LoadBalanced
    RestTemplate getTemplate() {
        return new RestTemplate();
    }

    @Autowired
    private RestTemplate template;

    public String say() {

        return template.getForObject("http://SERVICEB/hello?name=sen", String.class);
    }
}
